package com.helper.service.impl;

import com.helper.entity.Over;
import com.helper.dao.OverDao;
import com.helper.service.OverService;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;

import javax.annotation.Resource;
import java.util.List;


/**
 * (Over表)服务实现类
 *
 * @author lkc
 */
@Service("overServiceImpl")
public class OverServiceImpl implements OverService {
    @Resource
    private OverDao overDao;

    /**
     * 通过ID查询单条数据
     *
     * @param historyrecordid 主键
     * @return 实例对象
     */
    @Override
    public Over selectById(Integer historyrecordid) {
        return this.overDao.selectById(historyrecordid);
    }

    /**
     * 分页查询
     *
     * @param current 当前页
     * @param size    每一页的条数
     * @return 对象列表
     */
    @Override
    public PageInfo<Over> selectPage(int current, int size) {
        PageHelper.startPage(current, size);
        List<Over> dataList = overDao.selectAll();
        return new PageInfo<>(dataList);
    }

    /**
     * 查询所有
     *
     * @return 实例对象的集合
     */
    @Override
    public List<Over> selectAll() {
        return this.overDao.selectAll();
    }

    /**
     * 根据条件查询
     *
     * @return 实例对象的集合
     */
    @Override
    public List<Over> selectList(Over over) {
        return this.overDao.selectList(over);
    }

    /**
     * 新增数据
     *
     * @param over 实例对象
     * @return 实例对象
     */
    @Override
    @Transactional
    public int insert(Over over) {
        return this.overDao.insert(over);
    }

    /**
     * 批量新增
     *
     * @param overs 实例对象的集合
     * @return 生效的条数
     */
    @Override
    @Transactional
    public int batchInsert(List<Over> overs) {
        return this.overDao.batchInsert(overs);
    }

    /**
     * 修改数据
     *
     * @param over 实例对象
     * @return 实例对象
     */
    @Override
    @Transactional
    public Over update(Over over) {
        this.overDao.update(over);
        return this.selectById(over.getHistoryrecordid());
    }

    /**
     * 通过主键删除数据
     *
     * @param historyrecordid 主键
     * @return 是否成功
     */
    @Override
    @Transactional
    public int deleteById(Integer historyrecordid) {
        return this.overDao.deleteById(historyrecordid);
    }

    /**
     * 查询总数据数
     *
     * @return 数据总数
     */
    @Override
    public int count() {
        return this.overDao.count();
    }
}
